# -*- coding:utf-8 -*-

import ConfigParser,time,datetime

def writeToConfig (aCard,aCode):

	tmpCard = str(aCard)
	tmpCode = str(aCode)

	tmpConfig = ConfigParser.ConfigParser()
	tmpConfig.read("code.config")
	tmpSections = tmpConfig.sections()

	if not tmpSections or len(tmpSections) <= 0:
		updateConfig(tmpCard, tmpCard)

	

def updateConfig (aCard, aCode):
	tmpConfig.add_section(aCard) 
	tmpConfig.set(aCard, 'card', aCard)
	tmpConfig.set(aCard, 'code', aCode)
	tmpConfig.set(aCard, 'time', int(time.time()))
	tmpConfig.write(open("tcode.config", "w"))	

# def readFromConfig (aCard):
